package com.hhkj.admin.invoice.common.cont;

import com.ruoyi.common.exception.GlobalException;
import lombok.AllArgsConstructor;
import lombok.Getter;

public class InvoiceConst {

    public static final String EXPORT_EXCEL_TITLE = "发票数据汇总";

    @AllArgsConstructor
    @Getter
    public enum Status {

        NON("未生效，待上传发票后生效", "non", "申请中"),

        EFFECTIVE("有效", "effective", "已开发票"),

        INVALID("已作废", "invalid", "已作废"),

        REAPPLIED("已经重新申请过了", "reapplied", "已作废");

        private final String desc;

        private final String code;

        private final String name;

        public static String getNameByCode(String code) {
            for (Status value : Status.values()) {
                if (value.code.equals(code)) {
                    return value.name;
                }
            }
            throw new GlobalException("找不到对应的code，请联系管理员");
        }
    }

    @AllArgsConstructor
    @Getter
    public enum TypeCode {

        ORDINARY_ELECTRONIC("普通电子发票", "ordinaryElectronic");

        private final String name;

        private final String code;

        public static String getNameByCode(String code) {
            for (TypeCode value : TypeCode.values()) {
                if (value.code.equals(code)) {
                    return value.name;
                }
            }
            throw new GlobalException("找不到对应的code，请联系管理员");
        }
    }

    @AllArgsConstructor
    @Getter
    public enum TitleTypeCode {

        PERSON("个人发票", "person"),

        ENTERPRISE("企业发票", "enterprise");

        private final String name;

        private final String code;

        public static String getNameByCode(String code) {
            for (TitleTypeCode value : TitleTypeCode.values()) {
                if (value.code.equals(code)) {
                    return value.name;
                }
            }
            throw new GlobalException("找不到对应的code，请联系管理员");
        }

        @Override
        public String toString() {
            return this.code;
        }
    }
}
